﻿using Application.AppService;
using Application.AppService.CFFKAppService;
using AutoMapper;
using Domain.Entity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using static System.Runtime.InteropServices.JavaScript.JSType;

namespace UI.Controllers.Customization_Settings_客户化设置_.Human_resource_file_management_人力资源档案管理_
{
	public class CFFKController : Controller
	{
		private readonly ICFFKAppService cFFKAppService;
		private readonly IMapper mapper;

		public CFFKController(ICFFKAppService cFFKAppService ,IMapper mapper)
        {
			this.cFFKAppService = cFFKAppService;
			this.mapper = mapper;
		}
        public IActionResult Index()
		{
			return View();
		}
		public async Task<IActionResult> AddCFFK(CFFKAddDto cFFKAddDto)
		{
			CFFK cFFK= mapper.Map<CFFK>(cFFKAddDto);
			bool i = await cFFKAppService.AddCFFKAsync(cFFK);
			return Json(i);
		}
		public async Task<IActionResult> UpdateCFFK(CFFK cFFK)
		{
			bool i = await cFFKAppService.UpdateCFFKAsync(cFFK);
			return Json(i);
		}
		public async Task<IActionResult> GetCFFK()
		{
			List<CFFK> cFFKs = await cFFKAppService.SelectCFFKAsync();
			return Json(cFFKs);
			
		}
		public async Task<IActionResult> DeleteCFFK(int id )
        {
            bool i = await cFFKAppService.DeleteCFFKAsync(id);
            return Json(i);
        }
	}
}